package br.com.ufrn.aipetro.ga.controller.maintenance;
import java.sql.Date;
import java.util.List;

import br.com.ufrn.aipetro.ga.controller.interfaces.AbstractController;
import br.com.ufrn.aipetro.ga.domain.entity.device.maintenance.Maintenance;
import br.com.ufrn.aipetro.ga.domain.entity.device.maintenance.MaintenanceType;
import br.com.ufrn.aipetro.ga.persist.interfaces.DaoFactory;

public class TypeMaintenanceController extends AbstractController<MaintenanceType> {
	
	DaoFactory daoFactory;
	
	public TypeMaintenanceController(DaoFactory factory) {
		this.daoFactory = factory;
		setModel(new MaintenanceType());
	}
	
	public void changeName(String name) {
		getModel().setName(name);
	}
	
	public void persistInsert() {
		daoFactory.beginTransaction();
		daoFactory.createMaintenanceTypeDao().insert(getModel());
		daoFactory.commitTransaction();
	}
	
	public void persistUpdate() {
		daoFactory.beginTransaction();
		daoFactory.createMaintenanceTypeDao().update(getModel());
		daoFactory.commitTransaction();
	}
	
	public List<MaintenanceType> persistSearchAllMaintenance() {
		daoFactory.beginTransaction();
		List<MaintenanceType> listMaintenanceType = daoFactory.createMaintenanceTypeDao().searchAll();
		daoFactory.commitTransaction();
		return listMaintenanceType;
	}
	
	

}
